// See https://sequelize.org/master/manual/model-basics.html
// for more of what you can do here.
const Sequelize = require('sequelize');
const DataTypes = Sequelize.DataTypes;

module.exports = function (app) {
  const sequelizeClient = app.get('sequelizeClient');
  const medmanage = sequelizeClient.define('medmanage', {
    img: {
      type: DataTypes.STRING,
    },
    medsort: {
      type: DataTypes.STRING,
      allowNull:false
    },
    medname: {
      type: DataTypes.STRING,
      allowNull:false
    },
    mednum: {
      type: DataTypes.STRING,
      allowNull:false
    },
    model: {
      type: DataTypes.STRING,
    },
    price: {
      type: DataTypes.DECIMAL(10,2),
      allowNull:false
    },
    repnum: {
      type: DataTypes.INTEGER,
      default:0
    },
    unit: {
      type: DataTypes.STRING,
    },
    director: {
      type: DataTypes.STRING,
    },
    supplier: {
      type: DataTypes.STRING,
      allowNull:false
    },
    state: {
      type: DataTypes.STRING,
      allowNull:false
    },
    //标签
    label:DataTypes.STRING,
    // 成本价
    cprice:DataTypes.DECIMAL(10,2),
    // 特价
    tprice:DataTypes.DECIMAL(10,2),
    // 是否销售
    issale:DataTypes.BOOLEAN,
    // 描述
    describe:DataTypes.TEXT
  }, {
    hooks: {
      beforeCount(options) {
        options.raw = true;
      }
    }
  });

  // eslint-disable-next-line no-unused-vars
  medmanage.associate = function (models) {
    // Define associations here
    // See https://sequelize.org/master/manual/assocs.html
  };

  return medmanage;
};
